<?php
// +----------------------------------------------------------------------
// | User: DaMing
// +----------------------------------------------------------------------
// | Email: 3228985941@qq.com
// +----------------------------------------------------------------------
// | Date: 2021/12/12
// +----------------------------------------------------------------------
// | Time: 21:59
// +----------------------------------------------------------------------

namespace app\adminapi\controller;


use app\adminapi\validate\AdminValidate;
use app\dao\SysAdminDao;
use app\dm\basic\AdminBaseController;
use app\Request;

class Test extends AdminBaseController
{
    // 测试
    public function index(Request $request)
    {
        $args = $request->only([
            'AdminType',
            'Keywords',
            'Page',
            'Limit'
        ], 'get');
        validate(AdminValidate::class )->scene('list')->check($args);
        dump('adminapi/test');
    }

    // 权限路由测试
    public function auth(Request $request)
    {
        dump($request->admin->id);
        dump(222222222);die;
    }

    // token测试路由
    public function token(Request $request,SysAdminDao $sysAdminDao)
    {
        $admin = $sysAdminDao->getAdmin(1);

        // 创建token
        $params = $admin->toArray();
        unset($params['password']);
        unset($params['salt']);
        $data = $this->createToken($admin, $type = false,$params);

//        $data = $sysAdminDao->getList([],1,10);
        return $this->responseSuccess($data);
    }

}